home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 1.0 KB | 54 lines | [TEXT/CWIE] |
- // Buffer.h
-
- #ifndef Buffer_h
- #define Buffer_h
-
- #ifndef Data_h
- #include "Data.h"
- #endif
- #ifndef ConstData_h
- #include "ConstData.h"
- #endif
-
- class ConstBuffer;
-
- class Buffer
- {
- private:
- Data space;
- uint32 mark;
-
- // not implemented:
- Buffer( const Buffer& );
- void operator=( const Buffer& );
-
- public:
- Buffer( Data );
-
- void Reset() { mark = 0; }
- void Reset( Data );
-
- inline void AdvanceMark( uint32 amount );
-
- ConstData Used() const { return space.Head( mark ); }
- Data Unused() const { return space.Tail( mark ); }
-
- uint32 TotalLength() const { return space.Length(); }
- uint32 UsedLength() const { return mark; }
- uint32 UnusedLength() const { return space.Length() - mark; }
-
- bool IsEmpty() const { return mark == 0; }
- bool IsFull() const { return mark >= space.Length(); }
-
- void operator<<( ConstData );
- void operator<<( ConstBuffer& );
- };
-
- inline void Buffer::AdvanceMark( uint32 amount )
- {
- Assert( amount <= UnusedLength() );
- mark += amount;
- }
-
- #endif
-